home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / comm / net / rhslip38_9_030.lha / rhslip / src / slip_device.asm < prev    next >
Assembly Source File  |  1994-01-26  |  3KB  |  179 lines

  1. **
  2. ** $Source: /m/lerppu/u3/projects/Dec93/ohtatcp/amitcp/src/devs/rhslip/RCS/slip_device.asm,v $
  3. ** $State: Exp $
  4. ** $Revision: 37.4 $
  5. ** $Date: 1994/01/03 22:09:47 $
  6. ** $Author: ppessi $
  7. **
  8. ** Amiga SANA2 Example SLIP Device Driver
  9. **
  10. ** (C) Copyright 1992 Commodore-Amiga, Inc.
  11. **
  12.  
  13.  
  14.     SECTION firstsection
  15.  
  16.     NOLIST
  17.  
  18.     include "exec/types.i"
  19.     include "exec/devices.i"
  20.     include "exec/initializers.i"
  21.     include "exec/memory.i"
  22.     include "exec/resident.i"
  23.     include "exec/io.i"
  24.     include "exec/ables.i"
  25.     include "exec/errors.i"
  26.     include "exec/tasks.i"
  27.     include "utility/tagitem.i"
  28.     include "dos/dos.i"
  29.     include "dos/dosextens.i"
  30.     include "dos/dostags.i"
  31.     include "devices/serial.i"
  32.     include "devices/sana2.i"
  33.     include "slip_device.i"
  34.     include "rhslip_rev.i"
  35.  
  36.     LIST
  37.  
  38. ABSEXECBASE    EQU    4    ;Absolute location of the pointer to exec.library base
  39. **
  40. ** First executable location
  41. **
  42.  
  43. FirstAddress:
  44.     moveq    #-1,d0
  45.     rts
  46.  
  47. SLIPPRI   EQU    5
  48.  
  49.     XREF    _SLIPName
  50.     XREF    EndCode
  51.  
  52. initDDescrip:
  53.                     ; STRUCTURE RT,0
  54.     DC.W    RTC_MATCHWORD        ; UWORD RT_MATCHWORD (Magic cookie)
  55.     DC.L    initDDescrip        ; APTR    RT_MATCHTAG  (Back pointer)
  56.     DC.L    EndCode         ; APTR    RT_ENDSKIP   (To end of this hunk)
  57.     DC.B    RTF_AUTOINIT        ; UBYTE RT_FLAGS     (magic-see "Init:")
  58.     DC.B    VERSION         ; UBYTE RT_VERSION
  59.     DC.B    NT_DEVICE        ; UBYTE RT_TYPE      (must be correct)
  60.     DC.B    SLIPPRI         ; BYTE    RT_PRI
  61.     DC.L    _SLIPName        ; APTR    RT_NAME      (exec name)
  62.     DC.L    idString        ; APTR    RT_IDSTRING  (text string)
  63.     DC.L    Init            ; APTR    RT_INIT
  64.                     ; LABEL RT_SIZE
  65.  
  66. ** This is an identifier tag to help in supporting the device
  67. ** format is 'name version.revision (dd MON yyyy)',<cr>,<lf>,<null>
  68.  
  69. idString:    VSTRING
  70.  
  71. ** Force word alignment
  72.  
  73.     CNOP    0,4
  74.  
  75. Init:
  76.     DC.L    SLIPDev_Sizeof    ; data space size
  77.     DC.L    DevFuncTable    ; pointer to function initializers
  78.     DC.L    0        ; pointer to data initializers (unused)
  79.     DC.L    DevInit     ; routine to run
  80.  
  81. **
  82. ** Standard System Routines
  83. **
  84.  
  85.     XREF    _DevOpen
  86.     XREF    _DevClose
  87.     XREF    _DevExpunge
  88.     XREF    _DevBeginIO
  89.     XREF    _DevAbortIO
  90.  
  91. **
  92. ** Other misc. routines
  93. **
  94.     XDEF    _ExtDeviceBase
  95.     XDEF    @IPToNum
  96.  
  97. V_DEF    MACRO
  98.     DC.W    \1+(*-DevFuncTable)
  99.     ENDM
  100.  
  101. DevFuncTable:
  102.     DC.W    -1
  103.     V_DEF    _DevOpen
  104.     V_DEF    _DevClose
  105.     V_DEF    _DevExpunge
  106.     V_DEF    DevReserved
  107.     V_DEF    _DevBeginIO
  108.     V_DEF    _DevAbortIO
  109.     DC.W    -1
  110.  
  111. **
  112. ** Rhialto: Our only global variable. Since it is constant as long as
  113. ** we're in existence, this is not harmful.
  114.  
  115. _ExtDeviceBase    dc.l    0
  116.  
  117. **
  118. ** initRoutine
  119. **
  120. ** Called after device has been allocated.
  121. ** This routine is single threaded
  122. **
  123. ** Register Usage
  124. **
  125. ** a3 - Pointer to temporary RAM
  126. ** a4 - Pointer to expansion.library base
  127. ** d0 - Pointer to device struct
  128. ** a6 - Pointer to Exec Base
  129.  
  130. DevInit:
  131.     movem.l a0/a5,-(sp)
  132.     movea.l d0,a5
  133.     move.l    d0,_ExtDeviceBase        ; Rhialto
  134.     move.w    #REVISION,LIB_REVISION(a5)
  135.     move.l    a6,sd_SysLib(a5)
  136.     move.l    a0,sd_SegList(a5)
  137.     lea.l    sd_Lock(a5),a0
  138.     jsrlib    InitSemaphore
  139.     move.l    a5,d0
  140.     movem.l (sp)+,a0/a5
  141.     rts
  142.  
  143. DevReserved:
  144.     moveq.l #0,d0
  145.     rts
  146.  
  147. @IPToNum:
  148.     movem.l d2,-(sp)
  149.     bsr.s    StrToNum
  150.     lsl.w    #8,d0
  151.     move.w    d0,d2
  152.     bsr.s    StrToNum
  153.     move.b    d0,d2
  154.     swap    d2
  155.     bsr.s    StrToNum
  156.     lsl.w    #8,d0
  157.     move.w    d0,d2
  158.     bsr.s    StrToNum
  159.     move.b    d0,d2
  160.     move.l    d2,d0
  161.     movem.l (sp)+,d2
  162.     rts
  163.  
  164. StrToNum:
  165.     moveq    #0,d0
  166.     moveq    #0,d1
  167. 1$    move.b    (a0)+,d1
  168.     cmp.b    #'0',d1
  169.     bcs.s    2$            ; was blo
  170.     cmp.b    #'9',d1
  171.     bhi.s    2$
  172.     sub.b    #'0',d1
  173.     mulu    #10,d0
  174.     add.w    d1,d0
  175.     bra.s    1$
  176. 2$    rts
  177.  
  178.     END
  179.